/**
 * Created by Administrator on 2016/11/14.
 */
(function(){
    var help={
        init:function(){
            this.aContent=$(".help_pic li");
            this.aBtn=$(".h_list li");

            this.aBtn.first().addClass("active");
            this.aContent.first().show();
            this.tab();
        },
        tab:function(){
            var _this=this;
            this.aBtn.on("mouseover",function(){
               $(this).addClass("active").siblings().removeClass("active");
                _this.aContent.eq($(this).index()).show().siblings().hide();
            });
        }
    };
    /*
    * 验证
    * */
    var validate={
        init:function(){
            this.validates();
        },
        validates:function(){
            $(".help_submit").on("click",function(){
                if($(".h_feedback .textarea").val()==""){

                    layer.msg("问题反馈不能为空", {icon:2,time:1000});
                    return false;
                }
                if($(".h_feedback .txt").val()==""){
                    layer.msg("电话号码不能为空", {icon:2,time:1000});
                    return false;
                }else if(!/^1\d{10}$/ig.test($(".h_feedback .txt").val())){
                    layer.msg("输入号码有误", {icon:2,time:1000});
                    return false;
                }
                return true;
            });
        }
    };
    /*
    * 旋转木马
    * */
    carousel={
        init:function(){
            this.aBtn=$(".help_about_lt li");
            this.aContent=$(".help_about_rg li");
            this.iLen=this.aBtn.length;
            this.MoveTime=200;

            this.arr=[
                {left:199,top:136,"z-index":3,opacity:1},
                {left:331,top:110,"z-index":2,opacity:0.95},
                {left:201,top:69,"z-index":1,opacity:0.9},
                {left:76,top:110,"z-index":2,opacity:0.95}
            ];
            this.default();
        },
        default:function(){
            var _this=this;
            this.aContent.hide().first().show();
            this.eachLi();
            this.rotate();
        },
        rotate:function(){
            var _this=this;
            this.aBtn.on("click",function(){
                var n=3-$(this).css("z-index");
                $(this).css("z-index",3);
                _this.aContent.hide().eq($(this).index()).show();
                if(parseFloat($(this).css("left"))>200){
                    for(var i=0;i<n;i++){
                        _this.arr.unshift(_this.arr.pop());
                        _this.eachLi();
                    }
                }else{
                    _this.arr.push(_this.arr.shift());
                    _this.eachLi();
                }
            });
        },
        eachLi:function(){
            var _this=this;
            for(var i=0;i<this.arr.length;i++){
                (function(i){
                    _this.aBtn.eq(i).animate(_this.arr[i],_this.MoveTime);
                })(i);

            }
        }
    };
    help.init();
    validate.init();
    carousel.init();
})();